<!DOCTYPE html>
<html class="x-admin-sm" lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>修改企业收获兼职信息</title>
    <meta content="webkit|ie-comp|ie-stand" name="renderer">
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" name="viewport" />
    <link rel="stylesheet" th:href="@{/layui/css/font.css}">
    <link rel="stylesheet" th:href="@{/layui/css/login.css}">
    <link rel="stylesheet" th:href="@{/layui/css/xadmin.css}">
    <script charset="utf-8" th:src="@{/layui/lib/layui/layui.js}"></script>
    <script th:src="@{/layui/js/xadmin.js}" type="text/javascript"></script>
    <style>
        .login {
            margin: 75px auto auto auto;
        }
    </style>
</head>
<body class="login-bg">

<div class="login layui-anim layui-anim-up">
    <div class="message">修改企业收获兼职信息</div>
    <div id="darkbannerwrap"></div>
    <form class="layui-form" method="post" >
        <label style="display: none">
            <input name="id" th:value="${collectMessage.id}">
        </label>
        <label>
            <select id="studentName" lay-verify="required" name="student.id">
                <option th:value="${collectMessage.student.id}">[[${collectMessage.student.studentName}]]</option>
            </select>
        </label>
        <hr class="hr15">
        <label>
            <select id="partTimeMessage" lay-verify="required" name="partTimeMessage.id">
                <option th:value="${collectMessage.partTimeMessage.id}">[[${collectMessage.partTimeMessage.id}]]</option>
            </select>
        </label>
        <hr class="hr15">
        <label>
            <input class="layui-input" id="collectTime" lay-verify="required" name="collectTime" placeholder="收藏时间" th:value="${#dates.format(collectMessage.collectTime,'yyyy-MM-dd HH:mm:ss')}" type="text" >
        </label>
        <hr class="hr15">
        <input lay-filter="add" lay-submit style="width:100%;" type="submit" value="修改信息">
        <hr class="hr20" >
    </form>
</div>

<script>
    layui.use([ 'form', 'jquery', 'laydate', 'layer' ], function(){
        const form = layui.form, $ = layui.jquery, layer = layui.layer,
            laydate = layui.laydate
        //时间选择器
        laydate.render({
            elem: '#collectTime',
            type: 'datetime'
        });
        // 获取下拉框信息 (学生信息)
        $.get("/student_option_message",{},function (data) {
            let list = data;
            const select = document.getElementById('studentName');
            if (list != null) {
                for (let c in list) {
                    let option = document.createElement("option");
                    option.setAttribute("value", list[c].id);
                    option.innerText = list[c].studentName;
                    select.appendChild(option)
                }
            }
            form.render('select');
        },"json");
        // 获取下拉框信息 (兼职信息)
        $.get("/part_time_message_option_message",{},function (data) {
            let list = data;
            const select = document.getElementById('partTimeMessage');
            if (list != null) {
                for (let c in list) {
                    let option = document.createElement("option");
                    option.setAttribute("value", list[c].id);
                    option.innerText = list[c].id;
                    select.appendChild(option)
                }
            }
            form.render('select');
        },"json");
        //监听提交
        form.on('submit(add)', function(data){
            $.ajax({
                url : "/admin_student_student_collect_message_save_or_edit",
                method : 'post',
                data : data.field,
                dataType : 'JSON',
                success:function(res){
                    if(res.code === 0){
                        //弹出提示，并在1秒后进行跳转
                        layer.alert("修改成功", {
                            icon : 6
                        }, function() {
                            //关闭当前frame
                            xadmin.close();

                            // 可以对父窗口进行刷新
                            xadmin.father_reload();
                            return false;
                        });
                    } else {
                        layer.msg("修改失败:" + res.msg);
                        return false;
                    }
                }
            });
            return false;
        });
    });
</script>
<!-- 底部结束 -->
</body>
</html>